using System;
using System.Collections.Generic;
using RpgServiceLib.StoryFlagVariable;

namespace RpgServiceLib.Quest
{
	public class SimpleQuestLog
	{
		public IList<string> ListOfLog {get; private set;}
	
		public SimpleQuestLog ()
		{			
			this.ListOfLog= new List<string>();
		}
		
		public void ConsumeChangeEvent(QuestChangeEvent qce)
		{
			ListOfLog.Add (CreateLogEntry(qce));
		}

		public void ConsumeStoryChangeEvent (StoryFlagVariableChangeEvent qce)
		{
			ListOfLog.Add (CreateLogEntry (qce));
		}
				
		protected string CreateLogEntry(QuestChangeEvent qce)
		{			
			if (qce.Allowed == QuestChangeAllowedType.IsOk)
			{
				return string.Format("Quest {0} changed. Type Of Value = {1}. Old Value = {2}. New Value = {3}", qce.Quest.NameOfQuest, qce.QuestChangeType, qce.ValueBefore, qce.ValueNowOrEventType);
			} else {
				return string.Format("Quest {0} not changed. Type Of Value = {1}. Old Value = {2}. New Value = {3}", qce.Quest.NameOfQuest, qce.QuestChangeType, qce.ValueBefore, qce.ValueNowOrEventType);			
			}
		}
		
		protected string CreateLogEntry(StoryFlagVariableChangeEvent qce)
		{			
			if (qce.AllowType == StoryFlagVariableChangeAllowType.IsAllowed) {
				return string.Format ("FlagOrVariable {0} changed. Type Of Value = {1}. Old Value = {2}. New Value = {3}",
				 qce.FlagVariable.NameOfVariable,
				  qce.FlagVariable.TypeOfFlagOrVariable,
				   qce.OldVal, qce.NewVal);
			} else {
				return string.Format ("FlagOrVariable {0} not changed. Type Of Value = {1}. Old Value = {2}. New Value = {3}",
				 qce.FlagVariable.NameOfVariable,
				  qce.FlagVariable.TypeOfFlagOrVariable,
				   qce.OldVal, qce.NewVal);
			}
		}
		
	}
}

